fn main() {
    // 1. 引用 env.get_free_a, 但是 get_free_a 由于引用了外部环境，所以进行了闭包处理
    var free_a = 1111
    var get_free_a = fn():int {
        return free_a
    }

    var first = fn() {
        println(free_a, get_free_a())
    }

    first()

    // 2. 引用 env.get_free_b, 此时 get_free_b 就是普通的 fn 没有引用外部的环境
    var gen_free_b = fn():int{
        return 2222
    }

    var free_c = 3333

    var second = fn() {
        println(free_a, gen_free_b(), free_c)
    }
    second()

    // 3. 多级嵌套环境引用
    var third = fn() {
        var free_d_0 = 44440
        var third2 = fn() {
            var free_d_1 = 44441
            var third3 = fn() {
                var free_d_2 = 44442
                var third4 = fn() {
                    println('in third 4', free_d_0, free_d_1, free_d_2)
                }
                third4()
                println('in third 3', free_d_0)
            }

            third3()
        }

        third2()
    }
    third()
}